import React, { useContext } from 'react';
import { context } from '../../components/StateBus';

function Counter2() {

  const { state, dispatch } = useContext(context);
  const onIncr = () => {
    dispatch({ type: 'incr2', payload: '333333222321dddd' });
  };
  console.log('counter2');
  return (
    <div>
      CounterTest Count: {state.count} {state.payload}
      <button onClick={() => dispatch({ type: 'reset2' })}>Reset</button>
      <button onClick={() => onIncr()}>+</button>
      <button onClick={() => dispatch({ type: 'decr2' })}>-</button>
    </div>
  );
}

export default Counter2;
